<?php
/**
 * Created by PhpStorm.
 * User: hgq
 * Date: 16/6/24
 * Time: 下午1:23
 */
use yii\helpers\Url;

?>

<script type="application/javascript">

    function filtergoods() {
        var super_inst_code = $("#hc_super_inst_code").val();
        var chiled_inst_code = $("#hc_chiled_inst").val();
        var code = $("#head_code").val();
        var name = $("#head_name").val();
        var brand = $("#head_brand").val();
        var is_hide = $("#head_is_hide").val();

        var data = {};
        data.super_inst_code = super_inst_code;
        data.chiled_inst_code = chiled_inst_code;
        data.code = code;
        data.name = name;
        data.brand = brand;
        data.is_hide = is_hide;

        $("#body_table").html('');
        requestHtml('hide-child-inst-part-goods', data, true, function (responseHtml) {
            $("#body_table").html(responseHtml);
        }, function () {
            $("#body_table").html('');
        });
    }

    function goodsHideSet(goods_code) {
        loading.show();
        var super_inst_code = $("#hc_super_inst_code").val();
        var child_inst_code = $("#hc_chiled_inst").val();
        var obj = document.getElementsByName("checkbox_is_hide");
        var checkedv = '';
        for (var i = 0; i < obj.length; i++) {
            if (goods_code == obj[i].value) {
                checkedv = obj[i].checked;
            }
        }
        //调用后台处理流程
//        alert(super_inst_code + ' ' + child_inst_code + '  ' + goods_code + '  ' + checkedv);
        var data = {};
        data.super_inst_code = super_inst_code;
        data.child_inst_code = child_inst_code;
        data.goods_code = goods_code;
        data.is_hide = checkedv;
        var re = requestJson("change-hide-child-inst-handler", data);
        loading.hide();

        if (re.status != 0) {
            $("#hint_message").text('操作失败！');
            $("#hintMessageModal").modal('show');
        }
    }


</script>

<!-- head filter-->
<div class="form-inline">
    <div class="pull-left">
        <div class="form-group">
            <input type="text" id="hc_super_inst_code" value="<?= $super_inst_code ?>" hidden>
            <label for="exampleInputPassword2">旗下机构</label>
            <select id="hc_chiled_inst" class="form-control" style="width: 180px" onchange="">
                <?php
                if ($childinst != null && $childinst != '') {
                    for ($i = 0; $i < count($childinst); $i++) {
                        ?>
                        <option value="<?= $childinst[$i]['code'] ?>"><?= $childinst[$i]['name'] ?></option>
                        <?php
                    }
                }
                ?>
            </select>
        </div>
        <div class="form-group">
            <label for="exampleInputEmail2" style=" margin-left: 5px">可见状态</label>
            <select class="form-control popovers" style="width: 160px;" id="head_is_hide">
                <option value="">全部</option>
                <option value="1">可见</option>
                <option value="0">不可见</option>
            </select>
        </div>
    </div>
</div>
<br>
<div class="form-inline">
    <div class="pull-right" style=" margin-top: 5px">
        <div class="form-group">
            <label class="sr-only" for="exampleInputEmail2">商品编码</label>
            <input type="text" class="form-control" id="head_code" placeholder="商品编码" value="">
        </div>
        <div class="form-group">
            <label class="sr-only" for="exampleInputPassword2">商品名称</label>
            <input type="text" class="form-control" id="head_name" placeholder="商品名称" value="">
        </div>
        <div class="form-group">
            <label class="sr-only" for="exampleInputPassword2">商品品牌</label>
            <input type="text" class="form-control" id="head_brand" placeholder="商品品牌" value="">
        </div>
        <button type="button" class="btn btn-primary" onclick="filtergoods()"><i class="fa fa-search"></i> 搜索
        </button>
    </div>
</div>
<!-- body table-->
<div id="body_table">
    <div class="table-responsive">
        <table class="table table-bordered table-hover table-condensed" style=" margin-top: 5px">
            <thead class="nowrap">
            <tr>
                <th style="width:30%">商品编码</th>
                <th style="width:50%">商品名称</th>
                <th style="width:10%">商品品牌</th>
                <th style="width:10%">是否可见</th>
            </tr>
            </thead>
            <tbody>

            </tbody>
        </table>
    </div>
</div>

